package com.nativetalk.controller.app.two.setmeal;

import com.nativetalk.base.RetInfo;
import com.nativetalk.bean.member.TdNtMember;
import com.nativetalk.common.Constants;
import com.nativetalk.common.util.JsonUtil;
import com.nativetalk.common.util.MemcachedUtils;
import com.nativetalk.controller.app.two.teacher.live.TeacherLiveController;
import com.nativetalk.service.membsetmeal.search.MembSetmealSearchService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * Created by lizhun on 15/12/9.
 */
@Controller
public class TwoSetmealController {
    private static Logger logger = Logger.getLogger(TwoSetmealController.class);
    @Resource
    private MembSetmealSearchService membSetmealSearchService;
    /**
     * @Purpose  套餐列表
     * @version  5.0
     * @time     2015-06-02
     * @author   lizhun
     * @return   RetInfo
     */
    @RequestMapping(value="/app/5/member/setmeal/list" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json")
    @ResponseBody
    public RetInfo unfinish(@RequestBody Map<String,String> map,
                            @RequestHeader(value = "token", required = false) String token) {
        try {
            //打印入参
            logger.info(Constants.prefix_in + JsonUtil.toJson(map));

            RetInfo retInfo;
            TdNtMember tdNtMember = (TdNtMember) MemcachedUtils.get(token);
            retInfo = membSetmealSearchService.findMembSetmealByMembId(tdNtMember,Integer.valueOf(map.get("currentPage")),10);

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            RetInfo retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }
    }
}


